package common;

import java.beans.XMLDecoder;
import java.io.FileInputStream;
import java.io.Serializable;
import java.util.HashMap;

public class User implements Serializable {
    //用户类，用于检测用户信息
    private String uname;
    private Integer upassword;

    public static HashMap getUsers() {
        HashMap<String,Integer> users=new HashMap<>();
        try {
            XMLDecoder xd = new XMLDecoder(new FileInputStream("users.xml"));
            users = (HashMap<String, Integer>) xd.readObject();
            xd.close();
        } catch (Exception e) {
            return users;
        }
        return users;
    }


    public User() {
    }

    public User(String uname, Integer upassword) {
        this.uname = uname;
        this.upassword = upassword;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public Integer getUpassword() {
        return upassword;
    }

    public void setUpassword(Integer upassword) {
        this.upassword = upassword;
    }

    @Override
    public String toString() {
        return "User{" +
                "uname='" + uname + '\'' +
                ", upassword=" + upassword +
                '}';
    }
}
